package main;

import java.io.IOException;
import java.sql.*;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Account
 */
public class Account extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Account() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String un = request.getParameter("uname");
		//Mike Earl
		//declare variables for customer info that will be used in the HTML;
		String firstName = null;
		String lastName = null;
		String address = null;
		String city = null;
		String prov = null;
		String postal = null;
		String country = null;
		String homePhone = null;
		String busPhone = null;
		String email = null;
		String password = null;
		Connection conn = null;
		Statement stmt = null;
		String sql = "Select * from Customers where CustEmail='" + un + "'";
		try {
			
			Class.forName("com.mysql.jdbc.Driver").newInstance();
			conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/travelexperts","root","root");
			stmt = conn.createStatement();
			ResultSet rs = stmt.executeQuery(sql);
			if (rs.next())
			{
				
				firstName = rs.getString(2);
				lastName = rs.getString(3);
				address = rs.getString(4);
				city = rs.getString(5);
				prov = rs.getString(6);
				postal = rs.getString(7);
				country = rs.getString(8);
				homePhone = rs.getString(9);
				busPhone = rs.getString(10);
				email = rs.getString(10);
				password = rs.getString(13);
			}
			else {
				System.out.println("no connection");
			}
			
			}catch(Exception e) {
				e.printStackTrace();
			}
		
			try {
				conn.close();
				stmt.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}

	}


